package com.guli.common.constant;
/*
 * @Author 罗
 * @date 2020/10/1 - 8:36 上午
 */

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Data;


public class WareConstant {


    public enum PurchaseStatusEnum implements IEnum<Integer> {

        //采购单状态[0新建，1已分配，2正在采购，3已完成，4采购失败]
        CREATED(0, "新建"),
        RECEIVED(1, "已领取"),
        PURCHASING(2, "正在采购"),
        FINISHED(3, "已完成"),
        FAILED(4, "有异常");

        //    @EnumValue
        private Integer status;

        @JsonValue //可以用在get方法或者属性字段上，一个类只能用一个，当加上@JsonValue注解是，序列化是只返回这一个字段的值。
        private String message;


        PurchaseStatusEnum(Integer status, String message) {
            this.status = status;
            this.message = message;
        }

        /*
        没什么用，反序列化的时候也不会执行
        @JsonCreator
        WarePurchaseStatusConstant(@JsonProperty Integer status) {
            System.out.println("通过jsonCreater来反序列化的");
            this.status = status;
        }*/

        @Override
        public Integer getValue() {
            return this.status;
        }

        @Override
        public String toString() {
            return this.message;
        }
    }


    public enum PurchaseDetailStatusEnum implements IEnum<Integer> {

        //采购单状态[0新建，1已分配，2正在采购，3已完成，4采购失败]
        CREATED(0, "新建"),
        ASSIGNED(1, "已分配"),
        PURCHASING(2, "正在采购"),
        FINISHED(3, "已完成"),
        FAILED(4, "采购失败");

        //    @EnumValue
        private Integer status;

        @JsonValue //可以用在get方法或者属性字段上，一个类只能用一个，当加上@JsonValue注解是，序列化是只返回这一个字段的值。
        private String message;


        PurchaseDetailStatusEnum(Integer status, String message) {
            this.status = status;
            this.message = message;
        }

        /*
        没什么用，反序列化的时候也不会执行
        @JsonCreator
        WarePurchaseStatusConstant(@JsonProperty Integer status) {
            System.out.println("通过jsonCreater来反序列化的");
            this.status = status;
        }*/

        @Override
        public Integer getValue() {
            return this.status;
        }

        @Override
        public String toString() {
            return this.message;
        }
    }

    /**
     * 库存交换机
     * */
    public static final String STOCK_EVENT_EXCHANGE = "stock.event.exchange";

    /**
     * 库存延时队列
     * */
    public static final String STOCK_DELAY_QUEUE="stock.delay.queue";

    /**
     * 释放库存队列
     * */
    public static final String STOCK_RELEASE_QUEUE="stock.release.queue";

    /**
     * 锁定库存路由key
     * */
    public static final String STOCK_LOCKED_DELAY_ROUTING_KEY = "stock.locked.delay.routingKey";

    /**
     * 释放库存的路由key
     * "#" 表示所有、全部的意思；
     * "*" 只匹配到一个词。
     * */
    public static final String STOCK_RELEASE_ROUTING_KEY = "stock.release.#";

    /**
     * 订单取消之后，直接发送消息让库存解锁的路由key
     * */
    public static final String STOCK_RELEASE_CANCEL_ORDER_ROUTING_KEY = "stock.release.cancelOrder.routingKey";

    /**
     * 绑定时，将此队列使用 stock.locked.routingKey 路由key绑定到 stock.event.exchange 交换机上
     * 表 wms_ware_order_task_detail 监听的队列，将锁库存信息写如数据库
     * */
    public static final String STOCK_RECORD_QUEUE = "stock.record.queue";

    public static final String STOCK_LOCKED_RECORD_ROUTING_KEY = "stock.locked.record.routingKey";

    public static final String STOCK_LOCKED_ROUTING_KEY = "stock.locked.#";

    /**
     * 扣减库存的交换机以及路由key
     */
    public static final String STOCK_DEDUCTION_QUEUE = "stock.deduct.queue";

    public static final String STOCK_DEDUCTION_ROUTING_KEY = "stock.deduct.routingKey";

    /**
     * 表 wms_ware_order_task_detail 的锁定状态
     * */
    public enum LockStatus{
        LOCKED(1,"已锁定"),
        UNLOCKED(2,"已解锁"),
        DEDUCTION(3,"已扣减");

        @JsonValue	//标记响应json值
        @EnumValue//标记数据库存的值是code
        private Integer code;

        private String message;

        LockStatus(Integer code, String message) {
            this.code = code;
            this.message = message;
        }

        public Integer getCode() {
            return code;
        }

        public String getMessage() {
            return message;
        }
    }

}

